
package ui.activity.poscontrol.adapter;

import android.content.Context;
import android.view.View;

import net.ck.hzq.R;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import base.BaseViewHolder;
import base.SuperBaseAdapter;
import event.SelectRedballEvent;
import ui.activity.poscontrol.beanmodel.RedBallBean;
import util.SysUtils;


/**
 *POS查询列表适配器
 * Created by chenjian on 19/2/27
 */
public class RedBallCanUseAdapter extends SuperBaseAdapter<RedBallBean.RecordsBean> {

    Context mContext;
    List<RedBallBean.RecordsBean> mData=new ArrayList<>();
    String mredballid;//1可用2已使用3已过期
    public RedBallCanUseAdapter(Context context , List<RedBallBean.RecordsBean> data, String redballid) {
        super(context,data);
        mContext = context;
        mredballid = redballid;
        mData = data;
    }
    public void refresh() {
    }

    @Override
    protected void convert(BaseViewHolder holder, final RedBallBean.RecordsBean item, final int position) {
        holder.setText(R.id.redballtype,item.getName());
        holder.setText(R.id.redballtime,"限"+ SysUtils.sf5.format(new Date(item.getCreateTime())) +"-"+SysUtils.sf5.format(new Date(item.getExpireTime())));
        holder.setText(R.id.desc,item.getComment());
        holder.setText(R.id.redballmoney,item.getAmount());

        if(mredballid.equals(item.getTicketNo())){
            holder.getView(R.id.selectimg).setBackgroundResource(R.mipmap.redballselected);
        }else{
            holder.getView(R.id.selectimg).setBackgroundResource(R.mipmap.redballselect);
        }
        holder.setOnClickListener(R.id.grouplayout, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(new SelectRedballEvent(position, "", ""));

            }
        });
    }



    @Override
    protected int getItemViewLayoutId(int position, RedBallBean.RecordsBean item) {
        return R.layout.redballselectitem;
    }

}
